<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<script>

description("This tests the constructor for the AnimationEvent DOM class.");

// No initializer is passed.
shouldBe("new AnimationEvent('eventType').bubbles", "false");
shouldBe("new AnimationEvent('eventType').cancelable", "false");
shouldBeEqualToString("new AnimationEvent('eventType').animationName", "");
shouldBe("new AnimationEvent('eventType').elapsedTime", "0");

// bubbles is passed.
shouldBe("new AnimationEvent('eventType', { bubbles: false }).bubbles", "false");
shouldBe("new AnimationEvent('eventType', { bubbles: true }).bubbles", "true");

// cancelable is passed.
shouldBe("new AnimationEvent('eventType', { cancelable: false }).cancelable", "false");
shouldBe("new AnimationEvent('eventType', { cancelable: true }).cancelable", "true");

// animationName is passed.
// Strings.
shouldBeEqualToString("new AnimationEvent('eventType', { animationName: 'doremi' }).animationName", "doremi");
shouldBeEqualToString("new AnimationEvent('eventType', { animationName: '' }).animationName", "");

// Non-strings.
shouldBeEqualToString("new AnimationEvent('eventType', { animationName: undefined }).animationName", "");
shouldBeEqualToString("new AnimationEvent('eventType', { animationName: null }).animationName", "null");
shouldBeEqualToString("new AnimationEvent('eventType', { animationName: false }).animationName", "false");
shouldBeEqualToString("new AnimationEvent('eventType', { animationName: true }).animationName", "true");
shouldBeEqualToString("new AnimationEvent('eventType', { animationName: 12345 }).animationName", "12345");
shouldBeEqualToString("new AnimationEvent('eventType', { animationName: 18446744073709551615 }).animationName", "18446744073709552000");
shouldBeEqualToString("new AnimationEvent('eventType', { animationName: NaN }).animationName", "NaN");
shouldBeEqualToString("new AnimationEvent('eventType', { animationName: [] }).animationName", "");
shouldBeEqualToString("new AnimationEvent('eventType', { animationName: [1, 2, 3] }).animationName", "1,2,3");
shouldBeEqualToString("new AnimationEvent('eventType', { animationName: {doremi: 12345} }).animationName", "[object Object]");
shouldBeEqualToString("new AnimationEvent('eventType', { animationName: {valueOf: function () { return 'doremi'; } } }).animationName", "[object Object]");

// elapsedTime is passed.
// Numeric values.
shouldBe("new AnimationEvent('eventType', { elapsedTime: 0 }).elapsedTime", "0");
shouldBe("new AnimationEvent('eventType', { elapsedTime: 123.45 }).elapsedTime", "123.45");
shouldBe("new AnimationEvent('eventType', { elapsedTime: -123.45 }).elapsedTime", "-123.45");
shouldBe("new AnimationEvent('eventType', { elapsedTime: 18446744073709551615 }).elapsedTime", "18446744073709551615");
shouldThrow("new AnimationEvent('eventType', { elapsedTime: NaN }).elapsedTime");
shouldThrow("new AnimationEvent('eventType', { elapsedTime: Infinity }).elapsedTime");
shouldThrow("new AnimationEvent('eventType', { elapsedTime: -Infinity }).elapsedTime");

// Non-numeric values.
shouldBe("new AnimationEvent('eventType', { elapsedTime: undefined }).elapsedTime", "0");
shouldBe("new AnimationEvent('eventType', { elapsedTime: null }).elapsedTime", "0");
shouldBe("new AnimationEvent('eventType', { elapsedTime: false }).elapsedTime", "0");
shouldBe("new AnimationEvent('eventType', { elapsedTime: true }).elapsedTime", "1");
shouldBe("new AnimationEvent('eventType', { elapsedTime: '' }).elapsedTime", "0");
shouldThrow("new AnimationEvent('eventType', { elapsedTime: 'doremi' }).elapsedTime");
shouldBe("new AnimationEvent('eventType', { elapsedTime: [] }).elapsedTime", "0");
shouldBe("new AnimationEvent('eventType', { elapsedTime: [123.45] }).elapsedTime", "123.45");
shouldThrow("new AnimationEvent('eventType', { elapsedTime: [123.45, 678.90] }).elapsedTime");
shouldThrow("new AnimationEvent('eventType', { elapsedTime: {doremi: 123.45} }).elapsedTime");
shouldBe("new AnimationEvent('eventType', { elapsedTime: {valueOf: function () { return 123.45 } } }).elapsedTime", "123.45");

// All initializers are passed.
shouldBe("new AnimationEvent('eventType', { bubbles: true, cancelable: true, animationName: 'doremi', elapsedTime: 123.45 }).bubbles", "true");
shouldBe("new AnimationEvent('eventType', { bubbles: true, cancelable: true, animationName: 'doremi', elapsedTime: 123.45 }).cancelable", "true");
shouldBe("new AnimationEvent('eventType', { bubbles: true, cancelable: true, animationName: 'doremi', elapsedTime: 123.45 }).animationName", "'doremi'");
shouldBe("new AnimationEvent('eventType', { bubbles: true, cancelable: true, animationName: 'doremi', elapsedTime: 123.45 }).elapsedTime", "123.45");
</script>
</body>
</html>
